package com.atguigu.gmall.product.controller;


import com.atguigu.gmall.model.product.SkuInfo;
import com.atguigu.gmall.product.service.SkuInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;


/**
 * @Controller   处理器
 * @ResponseBody 返回json数据
 */
@RestController
public class HelloController {



    @Autowired
    SkuInfoService skuInfoService;

    @GetMapping("/hello")
    public String hello() throws InterruptedException {

        System.out.println("hello调用...");
        TimeUnit.SECONDS.sleep(4);
        return "hello world!!!";
    }

    @GetMapping("/test/sku/{skuId}")
    public SkuInfo getSkuInfo(@PathVariable("skuId")Long skuId){

        return skuInfoService.getById(skuId);
    }

}
